Skip to content

Fail CI on ProseMirror schema drift - #1046

Closed
koutst wants to merge 1 commit into
claude/tiptap-prosemirror-overview-25ba23from
claude/kind-carson-567f73
Closed

Fail CI on ProseMirror schema drift#1046
koutst wants to merge 1 commit into
claude/tiptap-prosemirror-overview-25ba23from
claude/kind-carson-567f73

Conversation

@koutst

@koutst koutst commented Aug 19, 2026

Copy link
Copy Markdown
Member

Follow-up to #1040 (stacked on its branch; GitHub will retarget to main when #1040 merges and its branch is deleted).

What this adds

  • CI enforcement.github/workflows/schema-check.yml runs npm ci + npm run schema:export on every PR and push to main, and fails if that leaves any diff or untracked file under schemas/prosemirror/. The export is byte-deterministic, so any drift means an editor extension change (or a TipTap dependency bump) landed without regenerated schemas.
  • Pre-commit regeneration — a lint-staged entry regenerates and stages the schemas whenever staged changes touch components/Editor/extensions/, components/Comment/lib/, or the export script, so in the common case drift never reaches CI. Dependency-driven drift (e.g. a TipTap bump) is intentionally left to the CI check, since commit-time node_modules may not reflect an edited lockfile.
  • README — replaces the "enforcement is a planned follow-up" note with the actual mechanisms.

⚠️ Action required before the check can pass

npm ci in CI needs auth for the two private registries. Add these repo secrets (values are the same tokens as in your local .npmrc / Vercel env):

gh secret set TIPTAP_PRO_TOKEN --repo ResearchHub/web
gh secret set FONTAWESOME_NPM_AUTH_TOKEN --repo ResearchHub/web

The workflow fails early with a clear message while they're missing. (Note: like any secret-dependent check, it won't work for PRs from forks — fine for this repo's branch-based flow.)

Verification

  • Ran npm run schema:export on a clean checkout of this branch: both JSON files byte-identical to what's committed (determinism + freshness confirmed).
  • Simulated the pre-commit path: staged a schema-affecting edit (removed Underline from the comment extensions), ran the new lint-staged entry — comment-editor.json was regenerated with the underline mark dropped and staged automatically.
  • Glob matching tested against micromatch with positive/negative path cases (extension sources match; unrelated editor UI files, CSS, and the CJS stub don't).
  • Workflow YAML parse-validated.

🤖 Generated with Claude Code

CI: a schema-check workflow reruns npm run schema:export on every PR and
push to main, failing on any diff or untracked file under
schemas/prosemirror/ — the export is byte-deterministic, so drift means an
editor extension change (or a TipTap bump) landed without regenerated
schemas. npm ci needs TIPTAP_PRO_TOKEN and FONTAWESOME_NPM_AUTH_TOKEN repo
secrets for the private TipTap Pro / Font Awesome registries.

Pre-commit: a lint-staged entry regenerates and stages the schemas when
staged changes touch components/Editor/extensions/, components/Comment/lib/,
or the export script, so most drift never reaches CI.
@koutst
koutst requested a review from a team as a code owner August 19, 2026 13:59
@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web Ready Ready Preview Aug 19, 2026 2:01pm

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

} > .npmrc

- name: Install dependencies
run: npm ci

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6eea057aa1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +22 to +24
env:
TIPTAP_PRO_TOKEN: ${{ secrets.TIPTAP_PRO_TOKEN }}
FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep registry tokens away from pull-request scripts

For same-repository pull requests, these job-wide secrets remain available after checkout while both npm ci and the PR-controlled schema:export script execute, so a contributor can alter prepare, the export script, or an imported module to transmit both private-registry credentials. This is not limited to explicit export code: npm documents that npm ci runs install and prepare lifecycle scripts. Install with scripts disabled and ensure the environment variables and generated .npmrc are removed before executing any code from the pull request.

Useful? React with 👍 / 👎.

Comment thread package.json
],
"**/*.{ts,tsx}": "bash -c 'npm run type-check'"
"**/*.{ts,tsx}": "bash -c 'npm run type-check'",
"{components/Editor/extensions/**/*.{ts,tsx},components/Comment/lib/**/*.{ts,tsx},scripts/export-prosemirror-schema.ts}": "bash -c 'npm run schema:export && git add schemas/prosemirror'"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stage only the generated schema files

When this hook runs while a developer has an unrelated unstaged edit under schemas/prosemirror/, such as a README change, git add schemas/prosemirror stages that edit as well and can silently include it in the extension commit. As the Git documentation notes, supplying a directory recursively adds matching files beneath it; name the two generated JSON outputs explicitly instead.

Useful? React with 👍 / 👎.

@koutst koutst closed this Aug 19, 2026
@koutst
koutst deleted the claude/kind-carson-567f73 branch August 19, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants